import {configureStore} from "@reduxjs/toolkit";
import rootReducer from "@/store/RootReducer.ts";
import {persistReducer, persistStore} from 'redux-persist';
import storage from 'redux-persist/lib/storage';


const persistConfig = {
  key: 'root',
  storage,
  whitelist: ['layoutConfig', 'userInfo'],
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

// 将所有的 Reducer 交给 persistedReducer 管理
export const store = configureStore({
  reducer: {
    pr: persistedReducer,
  },

  // 其他配置项
  middleware: getDefaultMiddleware => getDefaultMiddleware({
    //关闭redux序列化检测
    serializableCheck: false
  })
});

export const persistor = persistStore(store);

export type StateType = ReturnType<typeof store.getState>;
